﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;

namespace MyAdressBookWPF.Helpers
{
    public class Command : ICommand
    {
        private readonly Action executeAction;
        private readonly Action<Object> executeActionObj;
        

        public Command(Action<Object> executeAction)
        {
            this.executeActionObj = executeAction;
        }

        public Command(Action executeAction)
        {
            this.executeAction = executeAction;

        }

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            if (executeAction != null)
                executeAction();
            else
                executeActionObj(parameter);

        }
    }
}
